@extends('layouts.default') @section('main')
    <link rel="stylesheet" href="/css/uniform.css" />
    <link rel="stylesheet" href="/css/select2.css" />
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="#" class="tip-bottom">全局设置</a>
                <a href="#" class="current">缓存管理</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span11">
                    {{--<a href="{{url('cache/create')}}"><button--}}
                    {{--class="btn">新增项目</button></a>--}}

                    <form action="{{url('cache/search')}}" method="post">
                        <table>
                            <tr>
                                <th>
                                    <label >项目名 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name" value="" placeholder="项目名" />
                                    </div>
                                </th>
                                <th>
                                    <label >action :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="action" value="" placeholder="action" />
                                    </div>
                                </th>

                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-info">查询</button>
                                    </div>
                                </th>
                            </tr>
                        </table>
                    </form>

                    <div class="widget-box">
                        <div class="widget-title">
                            <span class="icon"><i class="icon-th"></i></span>
                            <h5>缓存管理</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th>id</th>
                                    <th>缓存管理项目</th>
                                    <th>action</th>
                                    <th>点击清除</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($lists as $key => $list)
                                    <tr class="gradeX">
                                        <td>{{$list->id}}</td>
                                        <td>{{$list->name}}</td>
                                        <td>{{$list->action}}</td>
                                        <td class="center">
                                            @if(in_array('delete',$actions))<a data-original-title="删除" data-toggle="modal" class="tip cache_delete" cache_action="{{$list->action}}" href="#myAlert"><i class="icon-trash"></i></a>@endif
                                            {{--<a data-original-title="编辑" class="tip" href="{{url('cache/edit?id='.$list->id)}}"><i class="icon-pencil"></i></a>--}}
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div><?php echo $lists->render();?>
                </div>
            </div>
        </div>
        <div>
            <div id="myAlert" class="modal hide">
                <div class="modal-header">
                    <button data-dismiss="modal" class="close" type="button">×</button>
                    <h3>提示</h3>
                </div>
                <div class="modal-body">
                    <p>确认清除这些缓存吗？</p>
                </div>
                <div class="modal-footer">
                    <a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
                    <a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
                </div>
            </div>
            <form action="{{url('cache/del')}}" method="post"
                  id="cacheForm">
                <input type="hidden" name="action" value="0">
            </form>
        </div>
        <script src="/js/matrix.tables.js"></script>
        <script src="/js/common.js"></script>
        <script>
            $(".cache_delete").click(function(){
                var cache_action = $(this).attr("cache_action");
                $("input[name='action']").val(cache_action);
            });

            $(".btn-primary").click(function(){
                var cache_action = $("input[name='action']").val();
                if(cache_action == ''){
                    alert('参数异常');
                    return;
                }
                ajaxRequest($('#cacheForm').serializeArray(),$('#cacheForm').attr('action'),function(data){
                    if(data.status){
                        alert(data.message);
//                        window.location.href = data.forwardUrl;
                    }else{
                        alert(data.message);
                    }
                });
            });
        </script>
@stop
